<?php
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');
Header('X-UA-Compatible: IE=9');

session_start();
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Karte</title>
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, user-scalable=no">
		<meta charset="UTF-8">
		<link rel="icon" href="icons/favicon.ico" type="image/x-icon">
		<link rel="stylesheet" type="text/css" href="css/style.css">
		<link rel="stylesheet" type="text/css" href="css/simpletree.css" />
		<script type="text/javascript"
			src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
		<script type="text/javascript" src="javascript/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="javascript/mapscript.js.php"
			charset="utf-8">
		    </script>
		<script type="text/javascript">
		    	editMode = 2;
		    </script>
		<script type="text/javascript" src="javascript/simpletreemenu.js">
		
		/***********************************************
		* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
		* This notice MUST stay intact for legal use
		* Visit Dynamic Drive at www.dynamicdrive.com for full source code
		***********************************************/
		
		</script>
	</head>
	<body>
		<?php 
		require_once 'navbar.php';
		?>
		<table>
			<tr>
				<?php
				$types = $db->getWhereaboutTypes();
				while ($row = $types->fetch_assoc())
				{
					echo '<th class="icon">'.$row['name']."</th>\n";
				}
				?>
				<th class="other">Reviere</th>
				<th class="other">Anzeigen von</th>
				<th class="other">Anzeigen bis</th>
			</tr>
			<tr>
				<?php
				$types->data_seek(0);
				while ($row = $types->fetch_assoc())
				{
					echo '<td>'
						. '<label>'
						. '<input type="checkbox" checked="checked" '
						. 'onChange="onToggleWhereaboutType(' . $row['id'] . ')" />'
						. '<img src="'.$row['icon'].'" alt="markerIcon" /></label></td>'
						."\n";
				}
				?>
				<td>
					<input type="button" value="Anzeige anpassen" 
						onclick="$('#districtSelector').toggle();" />
				</td>
				<td>
					<form name="showSince">
						<select size="1" name="day" onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(1, 31, 2, false);
							?>
						</select> <select size="1" name="month"
							onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(1, 12, 2, false);
							?>
						</select> <select size="1" name="year"
							onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(2012, 0 + date("Y"), 4, false);
							?>
						</select>
					</form>
				</td>
				<td>
					<form name="showUntil">
						<select size="1" name="day" onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(1, 31, 2, true);
							?>
						</select> <select size="1" name="month"
							onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(1, 12, 2, true);
							?>
						</select> <select size="1" name="year"
							onchange="drawAllWhereabouts();">
							<?php
							$db->printOptionLoop(2012, 0 + date("Y"), 4, true);
							?>
						</select>
					</form>
				</td>
			</tr>
		</table>
		<div id="map_canvas"></div>
		<div id="loadingbg">
			<img id="loadingimg" src="icons/ajax-loader.gif" alt="loading" />
		</div>
		<!-- Auswahl der Reviere -->
		<div id="districtSelector">
			<ul id="treemenu" class="treeview">
			<?php 
				$hunters = $db->getHunters();
				while($row = $hunters->fetch_assoc()) : 
			?>
					<li><?php echo $row['name']." ".$row['firstname'] ?>
						<ul>
					<?php
						$districts = $db->getDistrictsByHunter($row['id']);
						while($dis = $districts->fetch_assoc()) :
					?>
						<li>
							<label>
								<input type="checkbox" checked="checked"
									onchange="onToggleDisplayDistrict(<?php echo $dis['id'] ?>);" />
								<?php echo $dis['name'] ?>
							</label>
						</li>
					<?php endwhile; ?>
						</ul>
					</li>
			<?php endwhile; ?>
			</ul>
			<!-- Treemenu erstellen -->
			<script type="text/javascript">
				//ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
				ddtreemenu.createTree("treemenu", false);
			</script>
		</div>
	</body>
</html>
